/**
 * @typedef CreateFriendLinkDto
 * @property {string} name.required - 友链名称
 * @property {string} logo.required - 友链logo
 * @property {string} link.required - 友链地址
 */

/**
 * @typedef DeleteBody
 * @property {integer[]} ids.required - id集合
 */

const express = require('express')
const router = express.Router()
const auth = require('@/middleware/auth.middleware')
const friendLinkController = require('@/controllers/friend_link.controller')

/**
 * 友情链接列表查询
 * @route GET /friend-link
 * @summary 友情链接列表查询
 * @group 友情链接
 * @returns {object} 200
 * @returns {Error}  default - Unexpected error
 * @access friend-link-permission:btn:find
 * @security JWT
 */
router.get('/', auth(), friendLinkController.findPage)

/**
 * 友情链接新增
 * @route POST /friend-link
 * @summary 友情链接新增
 * @group 友情链接
 * @param {CreateFriendLinkDto.model} CreateFriendLinkDto.body.required
 * @returns {object} 200
 * @returns {Error}  default - Unexpected error
 * @access friend-link-permission:btn:add
 * @security JWT
 */
router.post('/', auth(), friendLinkController.createFriendLink)

/**
 * 友情链接更新
 * @route PUT /friend-link
 * @summary 友情链接更新
 * @group 友情链接
 * @param {CreateFriendLinkDto.model} CreateFriendLinkDto.body.required
 * @returns {object} 200
 * @returns {Error}  default - Unexpected error
 * @access friend-link-permission:btn:edit
 * @security JWT
 */
router.put('/', auth(), friendLinkController.updateFriendLink)

/**
 * 友情链接删除
 * @route DELETE /friend-link
 * @summary 友情链接删除
 * @group 友情链接
 * @param {DeleteBody.model} DeleteBody.body.required
 * @returns {object} 200
 * @returns {Error}  default - Unexpected error
 * @access friend-link-permission:btn:delete
 * @security JWT
 */
router.delete('/', auth(), friendLinkController.deleteFriendLinks)

module.exports = router
